package com.flurry.sdk;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.TextUtils;
import com.flurry.android.FlurryEventRecordStatus;
import com.flurry.sdk.jf;
import com.flurry.sdk.ll;
import com.flurry.sdk.lq;
import java.io.File;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.atomic.AtomicInteger;

public class jh implements lq.a {
    static final String a = jh.class.getSimpleName();
    static int b = 100;
    static int c = 10;
    static int d = 1000;
    static int e = 160000;
    static int f = 50;
    private final List<jc> A = new ArrayList();
    private boolean B = true;
    private int C = 0;
    private final List<ja> D = new ArrayList();
    private int E = 0;
    private int F = 0;
    private final hs G = new hs();
    /* access modifiers changed from: package-private */
    public WeakReference<lk> g;
    File h;
    kf<List<jf>> i;
    public boolean j;
    boolean k;
    String l;
    byte m;
    Long n;
    /* access modifiers changed from: package-private */
    public boolean o = true;
    final kh<jm> p = new kh<jm>() {
        public final /* synthetic */ void a(kg kgVar) {
            jy.a().b(new ma() {
                public final void a() {
                    jh jhVar = jh.this;
                    jk.a();
                    jhVar.a(true, jk.c());
                }
            });
        }
    };
    private final AtomicInteger q = new AtomicInteger(0);
    private final AtomicInteger r = new AtomicInteger(0);
    /* access modifiers changed from: private */
    public final kh<ll> s = new kh<ll>() {
        public final /* synthetic */ void a(kg kgVar) {
            ll llVar = (ll) kgVar;
            if (jh.this.g == null || llVar.b == jh.this.g.get()) {
                switch (AnonymousClass8.a[llVar.c - 1]) {
                    case 1:
                        jh jhVar = jh.this;
                        lk lkVar = llVar.b;
                        Context context = (Context) llVar.a.get();
                        jhVar.g = new WeakReference<>(lkVar);
                        lp a2 = lp.a();
                        jhVar.k = ((Boolean) a2.a("LogEvents")).booleanValue();
                        a2.a("LogEvents", (lq.a) jhVar);
                        km.a(4, jh.a, "initSettings, LogEvents = " + jhVar.k);
                        jhVar.l = (String) a2.a("UserId");
                        a2.a("UserId", (lq.a) jhVar);
                        km.a(4, jh.a, "initSettings, UserId = " + jhVar.l);
                        jhVar.m = ((Byte) a2.a("Gender")).byteValue();
                        a2.a("Gender", (lq.a) jhVar);
                        km.a(4, jh.a, "initSettings, Gender = " + jhVar.m);
                        jhVar.n = (Long) a2.a("Age");
                        a2.a("Age", (lq.a) jhVar);
                        km.a(4, jh.a, "initSettings, BirthDate = " + jhVar.n);
                        jhVar.o = ((Boolean) a2.a("analyticsEnabled")).booleanValue();
                        a2.a("analyticsEnabled", (lq.a) jhVar);
                        km.a(4, jh.a, "initSettings, AnalyticsEnabled = " + jhVar.o);
                        jhVar.h = context.getFileStreamPath(".flurryagent." + Integer.toString(jy.a().d.hashCode(), 16));
                        jhVar.i = new kf<>(context.getFileStreamPath(".yflurryreport." + Long.toString(ly.i(jy.a().d), 16)), ".yflurryreport.", 1, new lj<List<jf>>() {
                            public final lg<List<jf>> a(int i) {
                                return new lf(new jf.a());
                            }
                        });
                        jhVar.a(context);
                        jhVar.a(true);
                        if (hr.a().a != null) {
                            jy.a().b(new ma() {
                                public final void a() {
                                    hr.a().a.a();
                                }
                            });
                        }
                        jy.a().b(new ma() {
                            public final void a() {
                                jh.this.e();
                            }
                        });
                        jy.a().b(new ma() {
                            public final void a() {
                                jh.d(jh.this);
                            }
                        });
                        if (jl.a().b()) {
                            jy.a().b(new ma() {
                                public final void a() {
                                    jh jhVar = jh.this;
                                    jk.a();
                                    jhVar.a(true, jk.c());
                                }
                            });
                            return;
                        } else {
                            ki.a().a("com.flurry.android.sdk.IdProviderFinishedEvent", jhVar.p);
                            return;
                        }
                    case 2:
                        jh jhVar2 = jh.this;
                        llVar.a.get();
                        jhVar2.a();
                        return;
                    case 3:
                        jh jhVar3 = jh.this;
                        llVar.a.get();
                        jhVar3.b();
                        return;
                    case 4:
                        ki.a().b("com.flurry.android.sdk.FlurrySessionEvent", jh.this.s);
                        jh.this.a(llVar.d);
                        return;
                    default:
                        return;
                }
            }
        }
    };
    private long t;
    private String u;
    private int v = -1;
    /* access modifiers changed from: private */
    public final List<jf> w = new ArrayList();
    private final Map<String, List<String>> x = new HashMap();
    private final Map<String, String> y = new HashMap();
    private final Map<String, jb> z = new HashMap();

    /* renamed from: com.flurry.sdk.jh$8  reason: invalid class name */
    static /* synthetic */ class AnonymousClass8 {
        static final /* synthetic */ int[] a = new int[ll.a.a().length];

        static {
            try {
                a[ll.a.a - 1] = 1;
            } catch (NoSuchFieldError e) {
            }
            try {
                a[ll.a.c - 1] = 2;
            } catch (NoSuchFieldError e2) {
            }
            try {
                a[ll.a.d - 1] = 3;
            } catch (NoSuchFieldError e3) {
            }
            try {
                a[ll.a.e - 1] = 4;
            } catch (NoSuchFieldError e4) {
            }
        }
    }

    public jh() {
        ki.a().a("com.flurry.android.sdk.FlurrySessionEvent", this.s);
    }

    public final synchronized void a() {
        this.v = lw.e();
        if (hr.a().c != null) {
            jy.a().b(new ma() {
                public final void a() {
                    hr.a().c.c();
                }
            });
        }
        if (this.o && hr.a().a != null) {
            jy.a().b(new ma() {
                public final void a() {
                    hr.a().a.b();
                }
            });
        }
    }

    public final synchronized void b() {
        a(false);
        jk.a();
        final long c2 = jk.c();
        jk.a();
        final long e2 = jk.e();
        jk.a();
        final long j2 = 0;
        jx h2 = jk.h();
        if (h2 != null) {
            j2 = h2.f;
        }
        jk.a();
        final int i2 = jk.g().e;
        if (this.o && hr.a().a != null) {
            jy.a().b(new ma() {
                public final void a() {
                    hr.a().a.a(c2);
                }
            });
        }
        jy.a().b(new ma() {
            public final void a() {
                jh.this.f();
            }
        });
        if (jl.a().b()) {
            jy.a().b(new ma() {
                public final void a() {
                    jf a2 = jh.this.a(c2, e2, j2, i2);
                    jh.this.w.clear();
                    jh.this.w.add(a2);
                    jh.this.d();
                }
            });
        }
    }

    public final synchronized void a(final long j2) {
        ki.a().a((kh<?>) this.p);
        jk.a();
        b(jk.e());
        jy.a().b(new ma() {
            public final void a() {
                if (jh.this.o && hr.a().a != null) {
                    hr.a().a.c();
                }
                if (hr.a().c != null) {
                    jy.a().b(new ma() {
                        public final void a() {
                            hr.a().c.c = true;
                        }
                    });
                }
            }
        });
        if (jl.a().b()) {
            jy.a().b(new ma() {
                public final void a() {
                    jh.this.a(false, j2);
                }
            });
        }
        lp.a().b("Gender", this);
        lp.a().b("UserId", this);
        lp.a().b("Age", this);
        lp.a().b("LogEvents", this);
    }

    public final void a(String str, Object obj) {
        char c2 = 65535;
        switch (str.hashCode()) {
            case -1752163738:
                if (str.equals("UserId")) {
                    c2 = 1;
                    break;
                }
                break;
            case -1720015653:
                if (str.equals("analyticsEnabled")) {
                    c2 = 4;
                    break;
                }
                break;
            case -738063011:
                if (str.equals("LogEvents")) {
                    c2 = 0;
                    break;
                }
                break;
            case 65759:
                if (str.equals("Age")) {
                    c2 = 3;
                    break;
                }
                break;
            case 2129321697:
                if (str.equals("Gender")) {
                    c2 = 2;
                    break;
                }
                break;
        }
        switch (c2) {
            case 0:
                this.k = ((Boolean) obj).booleanValue();
                km.a(4, a, "onSettingUpdate, LogEvents = " + this.k);
                return;
            case 1:
                this.l = (String) obj;
                km.a(4, a, "onSettingUpdate, UserId = " + this.l);
                return;
            case 2:
                this.m = ((Byte) obj).byteValue();
                km.a(4, a, "onSettingUpdate, Gender = " + this.m);
                return;
            case 3:
                this.n = (Long) obj;
                km.a(4, a, "onSettingUpdate, Birthdate = " + this.n);
                return;
            case 4:
                this.o = ((Boolean) obj).booleanValue();
                km.a(4, a, "onSettingUpdate, AnalyticsEnabled = " + this.o);
                return;
            default:
                km.a(6, a, "onSettingUpdate internal error!");
                return;
        }
    }

    /* access modifiers changed from: package-private */
    public final void a(Context context) {
        Bundle extras;
        if ((context instanceof Activity) && (extras = ((Activity) context).getIntent().getExtras()) != null) {
            km.a(3, a, "Launch Options Bundle is present " + extras.toString());
            for (String str : extras.keySet()) {
                if (str != null) {
                    Object obj = extras.get(str);
                    String obj2 = obj != null ? obj.toString() : "null";
                    this.x.put(str, new ArrayList(Arrays.asList(new String[]{obj2})));
                    km.a(3, a, "Launch options Key: " + str + ". Its value: " + obj2);
                }
            }
        }
    }

    /* access modifiers changed from: package-private */
    /* JADX WARNING: Removed duplicated region for block: B:32:0x0127  */
    /* JADX WARNING: Removed duplicated region for block: B:35:0x0143  */
    /* JADX WARNING: Removed duplicated region for block: B:45:0x01bf  */
    /* JADX WARNING: Removed duplicated region for block: B:46:0x01c3  */
    @android.annotation.TargetApi(18)
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void a(boolean r11) {
        /*
            r10 = this;
            r8 = 5
            r1 = 0
            r2 = -1
            if (r11 == 0) goto L_0x0091
            java.util.Map<java.lang.String, java.lang.String> r0 = r10.y
            java.lang.String r3 = "boot.time"
            long r4 = java.lang.System.currentTimeMillis()
            long r6 = android.os.SystemClock.elapsedRealtime()
            long r4 = r4 - r6
            java.lang.String r4 = java.lang.Long.toString(r4)
            r0.put(r3, r4)
            android.os.StatFs r0 = new android.os.StatFs
            java.io.File r3 = android.os.Environment.getRootDirectory()
            java.lang.String r3 = r3.getAbsolutePath()
            r0.<init>(r3)
            android.os.StatFs r3 = new android.os.StatFs
            java.io.File r4 = android.os.Environment.getExternalStorageDirectory()
            java.lang.String r4 = r4.getAbsolutePath()
            r3.<init>(r4)
            int r4 = android.os.Build.VERSION.SDK_INT
            r5 = 18
            if (r4 < r5) goto L_0x0155
            java.util.Map<java.lang.String, java.lang.String> r4 = r10.y
            java.lang.String r5 = "disk.size.total.internal"
            long r6 = r0.getAvailableBlocksLong()
            java.lang.String r6 = java.lang.Long.toString(r6)
            r4.put(r5, r6)
            java.util.Map<java.lang.String, java.lang.String> r4 = r10.y
            java.lang.String r5 = "disk.size.available.internal"
            long r6 = r0.getAvailableBlocksLong()
            java.lang.String r0 = java.lang.Long.toString(r6)
            r4.put(r5, r0)
            java.util.Map<java.lang.String, java.lang.String> r0 = r10.y
            java.lang.String r4 = "disk.size.total.external"
            long r6 = r3.getAvailableBlocksLong()
            java.lang.String r5 = java.lang.Long.toString(r6)
            r0.put(r4, r5)
            java.util.Map<java.lang.String, java.lang.String> r0 = r10.y
            java.lang.String r4 = "disk.size.available.external"
            long r6 = r3.getAvailableBlocksLong()
            java.lang.String r3 = java.lang.Long.toString(r6)
            r0.put(r4, r3)
        L_0x0075:
            java.util.Map<java.lang.String, java.lang.String> r0 = r10.y
            java.lang.String r3 = "carrier.name"
            com.flurry.sdk.js.a()
            java.lang.String r4 = com.flurry.sdk.js.b()
            r0.put(r3, r4)
            java.util.Map<java.lang.String, java.lang.String> r0 = r10.y
            java.lang.String r3 = "carrier.details"
            com.flurry.sdk.js.a()
            java.lang.String r4 = com.flurry.sdk.js.c()
            r0.put(r3, r4)
        L_0x0091:
            com.flurry.sdk.jy r0 = com.flurry.sdk.jy.a()
            android.content.Context r0 = r0.a
            java.lang.String r3 = "activity"
            java.lang.Object r0 = r0.getSystemService(r3)
            android.app.ActivityManager r0 = (android.app.ActivityManager) r0
            android.app.ActivityManager$MemoryInfo r3 = new android.app.ActivityManager$MemoryInfo
            r3.<init>()
            r0.getMemoryInfo(r3)
            java.util.Map<java.lang.String, java.lang.String> r4 = r10.y
            java.lang.StringBuilder r5 = new java.lang.StringBuilder
            java.lang.String r0 = "memory.available"
            r5.<init>(r0)
            if (r11 == 0) goto L_0x0197
            java.lang.String r0 = ".start"
        L_0x00b4:
            java.lang.StringBuilder r0 = r5.append(r0)
            java.lang.String r0 = r0.toString()
            long r6 = r3.availMem
            java.lang.String r5 = java.lang.Long.toString(r6)
            r4.put(r0, r5)
            int r0 = android.os.Build.VERSION.SDK_INT
            r4 = 16
            if (r0 < r4) goto L_0x00e9
            java.util.Map<java.lang.String, java.lang.String> r4 = r10.y
            java.lang.StringBuilder r5 = new java.lang.StringBuilder
            java.lang.String r0 = "memory.total"
            r5.<init>(r0)
            if (r11 == 0) goto L_0x019b
            java.lang.String r0 = ".start"
        L_0x00d8:
            java.lang.StringBuilder r0 = r5.append(r0)
            java.lang.String r0 = r0.toString()
            long r6 = r3.availMem
            java.lang.String r3 = java.lang.Long.toString(r6)
            r4.put(r0, r3)
        L_0x00e9:
            android.content.IntentFilter r0 = new android.content.IntentFilter     // Catch:{ Exception -> 0x01a2 }
            java.lang.String r3 = "android.intent.action.BATTERY_CHANGED"
            r0.<init>(r3)     // Catch:{ Exception -> 0x01a2 }
            com.flurry.sdk.jy r3 = com.flurry.sdk.jy.a()     // Catch:{ Exception -> 0x01a2 }
            android.content.Context r3 = r3.a     // Catch:{ Exception -> 0x01a2 }
            r4 = 0
            android.content.Intent r4 = r3.registerReceiver(r4, r0)     // Catch:{ Exception -> 0x01a2 }
            if (r4 == 0) goto L_0x01cf
            java.lang.String r0 = "status"
            r3 = -1
            int r0 = r4.getIntExtra(r0, r3)     // Catch:{ Exception -> 0x01a2 }
            r3 = 2
            if (r0 == r3) goto L_0x0109
            if (r0 != r8) goto L_0x019f
        L_0x0109:
            r0 = 1
        L_0x010a:
            java.lang.String r1 = "level"
            r3 = -1
            int r3 = r4.getIntExtra(r1, r3)     // Catch:{ Exception -> 0x01c6 }
            java.lang.String r1 = "scale"
            r5 = -1
            int r1 = r4.getIntExtra(r1, r5)     // Catch:{ Exception -> 0x01ca }
            r2 = r3
        L_0x0119:
            float r2 = (float) r2
            float r1 = (float) r1
            float r2 = r2 / r1
            java.util.Map<java.lang.String, java.lang.String> r3 = r10.y
            java.lang.StringBuilder r4 = new java.lang.StringBuilder
            java.lang.String r1 = "battery.charging"
            r4.<init>(r1)
            if (r11 == 0) goto L_0x01bf
            java.lang.String r1 = ".start"
        L_0x0129:
            java.lang.StringBuilder r1 = r4.append(r1)
            java.lang.String r1 = r1.toString()
            java.lang.String r0 = java.lang.Boolean.toString(r0)
            r3.put(r1, r0)
            java.util.Map<java.lang.String, java.lang.String> r1 = r10.y
            java.lang.StringBuilder r3 = new java.lang.StringBuilder
            java.lang.String r0 = "battery.remaining"
            r3.<init>(r0)
            if (r11 == 0) goto L_0x01c3
            java.lang.String r0 = ".start"
        L_0x0145:
            java.lang.StringBuilder r0 = r3.append(r0)
            java.lang.String r0 = r0.toString()
            java.lang.String r2 = java.lang.Float.toString(r2)
            r1.put(r0, r2)
            return
        L_0x0155:
            java.util.Map<java.lang.String, java.lang.String> r4 = r10.y
            java.lang.String r5 = "disk.size.total.internal"
            int r6 = r0.getAvailableBlocks()
            long r6 = (long) r6
            java.lang.String r6 = java.lang.Long.toString(r6)
            r4.put(r5, r6)
            java.util.Map<java.lang.String, java.lang.String> r4 = r10.y
            java.lang.String r5 = "disk.size.available.internal"
            int r0 = r0.getAvailableBlocks()
            long r6 = (long) r0
            java.lang.String r0 = java.lang.Long.toString(r6)
            r4.put(r5, r0)
            java.util.Map<java.lang.String, java.lang.String> r0 = r10.y
            java.lang.String r4 = "disk.size.total.external"
            int r5 = r3.getAvailableBlocks()
            long r6 = (long) r5
            java.lang.String r5 = java.lang.Long.toString(r6)
            r0.put(r4, r5)
            java.util.Map<java.lang.String, java.lang.String> r0 = r10.y
            java.lang.String r4 = "disk.size.available.external"
            int r3 = r3.getAvailableBlocks()
            long r6 = (long) r3
            java.lang.String r3 = java.lang.Long.toString(r6)
            r0.put(r4, r3)
            goto L_0x0075
        L_0x0197:
            java.lang.String r0 = ".end"
            goto L_0x00b4
        L_0x019b:
            java.lang.String r0 = ".end"
            goto L_0x00d8
        L_0x019f:
            r0 = r1
            goto L_0x010a
        L_0x01a2:
            r0 = move-exception
            r3 = r0
            r0 = r1
            r1 = r2
        L_0x01a6:
            java.lang.String r4 = a
            java.lang.StringBuilder r5 = new java.lang.StringBuilder
            java.lang.String r6 = "Error getting battery status: "
            r5.<init>(r6)
            java.lang.StringBuilder r3 = r5.append(r3)
            java.lang.String r3 = r3.toString()
            com.flurry.sdk.km.a((int) r8, (java.lang.String) r4, (java.lang.String) r3)
            r9 = r2
            r2 = r1
            r1 = r9
            goto L_0x0119
        L_0x01bf:
            java.lang.String r1 = ".end"
            goto L_0x0129
        L_0x01c3:
            java.lang.String r0 = ".end"
            goto L_0x0145
        L_0x01c6:
            r1 = move-exception
            r3 = r1
            r1 = r2
            goto L_0x01a6
        L_0x01ca:
            r1 = move-exception
            r9 = r1
            r1 = r3
            r3 = r9
            goto L_0x01a6
        L_0x01cf:
            r0 = r1
            r1 = r2
            goto L_0x0119
        */
        throw new UnsupportedOperationException("Method not decompiled: com.flurry.sdk.jh.a(boolean):void");
    }

    private synchronized void b(long j2) {
        for (jc next : this.A) {
            if (next.b && !next.c) {
                next.a(j2);
            }
        }
    }

    /* access modifiers changed from: package-private */
    public final synchronized jf a(long j2, long j3, long j4, int i2) {
        String str;
        String str2;
        Map<String, String> map;
        int e2;
        String str3;
        jf jfVar;
        jg jgVar = new jg();
        jgVar.a = ju.a().g();
        jgVar.b = j2;
        jgVar.c = j3;
        jgVar.d = j4;
        jgVar.e = this.y;
        jk.a();
        jx h2 = jk.h();
        if (h2 != null) {
            str = h2.d();
        } else {
            str = null;
        }
        jgVar.f = str;
        jk.a();
        jx h3 = jk.h();
        if (h3 != null) {
            str2 = h3.e();
        } else {
            str2 = null;
        }
        jgVar.g = str2;
        jk.a();
        jx h4 = jk.h();
        if (h4 != null) {
            map = h4.f();
        } else {
            map = null;
        }
        jgVar.h = map;
        jo.a();
        jgVar.i = jo.b();
        jo.a();
        jgVar.j = TimeZone.getDefault().getID();
        jgVar.k = i2;
        if (this.v != -1) {
            e2 = this.v;
        } else {
            e2 = lw.e();
        }
        jgVar.l = e2;
        if (this.l == null) {
            str3 = "";
        } else {
            str3 = this.l;
        }
        jgVar.m = str3;
        jgVar.n = jp.a().g();
        jgVar.o = this.F;
        jgVar.p = this.m;
        jgVar.q = this.n;
        jgVar.r = this.z;
        jgVar.s = this.A;
        jgVar.t = this.B;
        jgVar.v = this.D;
        jgVar.u = this.E;
        try {
            jfVar = new jf(jgVar);
        } catch (IOException e3) {
            km.a(5, a, "Error creating analytics session report: " + e3);
            jfVar = null;
        }
        if (jfVar == null) {
            km.e(a, "New session report wasn't created");
        }
        return jfVar;
    }

    public final synchronized void c() {
        this.F++;
    }

    public final synchronized FlurryEventRecordStatus a(String str, String str2, Map<String, String> map) {
        FlurryEventRecordStatus flurryEventRecordStatus;
        flurryEventRecordStatus = FlurryEventRecordStatus.kFlurryEventFailed;
        if (map != null) {
            if (!TextUtils.isEmpty(str2)) {
                map.put("sid+Tumblr", str2);
                flurryEventRecordStatus = a(str, map, false);
                km.a(5, a, "logEvent status for syndication:" + flurryEventRecordStatus);
            }
        }
        return flurryEventRecordStatus;
    }

    public final synchronized FlurryEventRecordStatus a(String str, Map<String, String> map, boolean z2) {
        FlurryEventRecordStatus flurryEventRecordStatus;
        final Map<String, String> map2;
        FlurryEventRecordStatus flurryEventRecordStatus2 = FlurryEventRecordStatus.kFlurryEventRecorded;
        if (!this.o) {
            flurryEventRecordStatus = FlurryEventRecordStatus.kFlurryEventAnalyticsDisabled;
            km.e(a, "Analytics has been disabled, not logging event.");
        } else {
            long elapsedRealtime = SystemClock.elapsedRealtime();
            jk.a();
            long d2 = elapsedRealtime - jk.d();
            final String b2 = ly.b(str);
            if (b2.length() == 0) {
                flurryEventRecordStatus = FlurryEventRecordStatus.kFlurryEventFailed;
            } else {
                jb jbVar = this.z.get(b2);
                if (jbVar != null) {
                    jbVar.a++;
                    km.e(a, "Event count incremented: " + b2);
                    flurryEventRecordStatus = FlurryEventRecordStatus.kFlurryEventRecorded;
                } else if (this.z.size() < b) {
                    jb jbVar2 = new jb();
                    jbVar2.a = 1;
                    this.z.put(b2, jbVar2);
                    km.e(a, "Event count started: " + b2);
                    flurryEventRecordStatus = flurryEventRecordStatus2;
                } else {
                    km.e(a, "Too many different events. Event not counted: " + b2);
                    flurryEventRecordStatus = FlurryEventRecordStatus.kFlurryEventUniqueCountExceeded;
                }
                if (!this.k || this.A.size() >= d || this.C >= e) {
                    this.B = false;
                } else {
                    if (map == null) {
                        map2 = Collections.emptyMap();
                    } else {
                        map2 = map;
                    }
                    if (map2.size() > c) {
                        km.e(a, "MaxEventParams exceeded: " + map2.size());
                        flurryEventRecordStatus = FlurryEventRecordStatus.kFlurryEventParamsCountExceeded;
                    } else {
                        jc jcVar = new jc(this.q.incrementAndGet(), b2, map2, d2, z2);
                        if (jcVar.b().length + this.C <= e) {
                            this.A.add(jcVar);
                            this.C = jcVar.b().length + this.C;
                            flurryEventRecordStatus = FlurryEventRecordStatus.kFlurryEventRecorded;
                            if (this.o && hr.a().a != null) {
                                jy.a().b(new Runnable() {
                                    public final void run() {
                                        hr.a().a.a(b2, (Map<String, String>) map2);
                                    }
                                });
                            }
                        } else {
                            this.C = e;
                            this.B = false;
                            km.e(a, "Event Log size exceeded. No more event details logged.");
                            flurryEventRecordStatus = FlurryEventRecordStatus.kFlurryEventLogCountExceeded;
                        }
                    }
                }
            }
        }
        return flurryEventRecordStatus;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:14:0x002b, code lost:
        r2 = android.os.SystemClock.elapsedRealtime();
        com.flurry.sdk.jk.a();
        r2 = r2 - com.flurry.sdk.jk.d();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:15:0x0037, code lost:
        if (r10 == null) goto L_0x008e;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:17:0x003d, code lost:
        if (r10.size() <= 0) goto L_0x008e;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:19:0x0043, code lost:
        if (r8.C >= e) goto L_0x008e;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:20:0x0045, code lost:
        r1 = r8.C - r0.b().length;
        r4 = new java.util.HashMap(r0.a());
        r0.a(r10);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:21:0x0061, code lost:
        if ((r0.b().length + r1) > e) goto L_0x00a1;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:23:0x006d, code lost:
        if (r0.a().size() <= c) goto L_0x0095;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:24:0x006f, code lost:
        com.flurry.sdk.km.e(a, "MaxEventParams exceeded on endEvent: " + r0.a().size());
        r0.b(r4);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:25:0x008e, code lost:
        r0.a(r2);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:30:?, code lost:
        r8.C = r1 + r0.b().length;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:35:?, code lost:
        r0.b(r4);
        r8.B = false;
        r8.C = e;
        com.flurry.sdk.km.e(a, "Event Log size exceeded. No more event details logged.");
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final synchronized void a(String r9, Map<String, String> r10) {
        /*
            r8 = this;
            r2 = 0
            monitor-enter(r8)
            java.util.List<com.flurry.sdk.jc> r0 = r8.A     // Catch:{ all -> 0x009e }
            java.util.Iterator r3 = r0.iterator()     // Catch:{ all -> 0x009e }
        L_0x0008:
            boolean r0 = r3.hasNext()     // Catch:{ all -> 0x009e }
            if (r0 == 0) goto L_0x0091
            java.lang.Object r0 = r3.next()     // Catch:{ all -> 0x009e }
            com.flurry.sdk.jc r0 = (com.flurry.sdk.jc) r0     // Catch:{ all -> 0x009e }
            boolean r1 = r0.b     // Catch:{ all -> 0x009e }
            if (r1 == 0) goto L_0x0093
            long r4 = r0.d     // Catch:{ all -> 0x009e }
            r6 = 0
            int r1 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1))
            if (r1 != 0) goto L_0x0093
            java.lang.String r1 = r0.a     // Catch:{ all -> 0x009e }
            boolean r1 = r1.equals(r9)     // Catch:{ all -> 0x009e }
            if (r1 == 0) goto L_0x0093
            r1 = 1
        L_0x0029:
            if (r1 == 0) goto L_0x0008
            long r2 = android.os.SystemClock.elapsedRealtime()     // Catch:{ all -> 0x009e }
            com.flurry.sdk.jk.a()     // Catch:{ all -> 0x009e }
            long r4 = com.flurry.sdk.jk.d()     // Catch:{ all -> 0x009e }
            long r2 = r2 - r4
            if (r10 == 0) goto L_0x008e
            int r1 = r10.size()     // Catch:{ all -> 0x009e }
            if (r1 <= 0) goto L_0x008e
            int r1 = r8.C     // Catch:{ all -> 0x009e }
            int r4 = e     // Catch:{ all -> 0x009e }
            if (r1 >= r4) goto L_0x008e
            int r1 = r8.C     // Catch:{ all -> 0x009e }
            byte[] r4 = r0.b()     // Catch:{ all -> 0x009e }
            int r4 = r4.length     // Catch:{ all -> 0x009e }
            int r1 = r1 - r4
            java.util.HashMap r4 = new java.util.HashMap     // Catch:{ all -> 0x009e }
            java.util.Map r5 = r0.a()     // Catch:{ all -> 0x009e }
            r4.<init>(r5)     // Catch:{ all -> 0x009e }
            r0.a((java.util.Map<java.lang.String, java.lang.String>) r10)     // Catch:{ all -> 0x009e }
            byte[] r5 = r0.b()     // Catch:{ all -> 0x009e }
            int r5 = r5.length     // Catch:{ all -> 0x009e }
            int r5 = r5 + r1
            int r6 = e     // Catch:{ all -> 0x009e }
            if (r5 > r6) goto L_0x00a1
            java.util.Map r5 = r0.a()     // Catch:{ all -> 0x009e }
            int r5 = r5.size()     // Catch:{ all -> 0x009e }
            int r6 = c     // Catch:{ all -> 0x009e }
            if (r5 <= r6) goto L_0x0095
            java.lang.String r1 = a     // Catch:{ all -> 0x009e }
            java.lang.StringBuilder r5 = new java.lang.StringBuilder     // Catch:{ all -> 0x009e }
            java.lang.String r6 = "MaxEventParams exceeded on endEvent: "
            r5.<init>(r6)     // Catch:{ all -> 0x009e }
            java.util.Map r6 = r0.a()     // Catch:{ all -> 0x009e }
            int r6 = r6.size()     // Catch:{ all -> 0x009e }
            java.lang.StringBuilder r5 = r5.append(r6)     // Catch:{ all -> 0x009e }
            java.lang.String r5 = r5.toString()     // Catch:{ all -> 0x009e }
            com.flurry.sdk.km.e(r1, r5)     // Catch:{ all -> 0x009e }
            r0.b(r4)     // Catch:{ all -> 0x009e }
        L_0x008e:
            r0.a((long) r2)     // Catch:{ all -> 0x009e }
        L_0x0091:
            monitor-exit(r8)
            return
        L_0x0093:
            r1 = r2
            goto L_0x0029
        L_0x0095:
            byte[] r4 = r0.b()     // Catch:{ all -> 0x009e }
            int r4 = r4.length     // Catch:{ all -> 0x009e }
            int r1 = r1 + r4
            r8.C = r1     // Catch:{ all -> 0x009e }
            goto L_0x008e
        L_0x009e:
            r0 = move-exception
            monitor-exit(r8)
            throw r0
        L_0x00a1:
            r0.b(r4)     // Catch:{ all -> 0x009e }
            r1 = 0
            r8.B = r1     // Catch:{ all -> 0x009e }
            int r1 = e     // Catch:{ all -> 0x009e }
            r8.C = r1     // Catch:{ all -> 0x009e }
            java.lang.String r1 = a     // Catch:{ all -> 0x009e }
            java.lang.String r4 = "Event Log size exceeded. No more event details logged."
            com.flurry.sdk.km.e(r1, r4)     // Catch:{ all -> 0x009e }
            goto L_0x008e
        */
        throw new UnsupportedOperationException("Method not decompiled: com.flurry.sdk.jh.a(java.lang.String, java.util.Map):void");
    }

    /* JADX WARNING: Removed duplicated region for block: B:10:0x001d  */
    /* JADX WARNING: Removed duplicated region for block: B:14:0x0057  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final synchronized void a(String r10, String r11, String r12, Throwable r13) {
        /*
            r9 = this;
            r0 = 0
            monitor-enter(r9)
            if (r10 == 0) goto L_0x0055
            java.lang.String r1 = "uncaught"
            boolean r1 = r1.equals(r10)     // Catch:{ all -> 0x0099 }
            if (r1 == 0) goto L_0x0055
            r1 = 1
        L_0x000d:
            int r2 = r9.E     // Catch:{ all -> 0x0099 }
            int r2 = r2 + 1
            r9.E = r2     // Catch:{ all -> 0x0099 }
            java.util.List<com.flurry.sdk.ja> r2 = r9.D     // Catch:{ all -> 0x0099 }
            int r2 = r2.size()     // Catch:{ all -> 0x0099 }
            int r3 = f     // Catch:{ all -> 0x0099 }
            if (r2 >= r3) goto L_0x0057
            long r0 = java.lang.System.currentTimeMillis()     // Catch:{ all -> 0x0099 }
            java.lang.Long r2 = java.lang.Long.valueOf(r0)     // Catch:{ all -> 0x0099 }
            com.flurry.sdk.ja r0 = new com.flurry.sdk.ja     // Catch:{ all -> 0x0099 }
            java.util.concurrent.atomic.AtomicInteger r1 = r9.r     // Catch:{ all -> 0x0099 }
            int r1 = r1.incrementAndGet()     // Catch:{ all -> 0x0099 }
            long r2 = r2.longValue()     // Catch:{ all -> 0x0099 }
            r4 = r10
            r5 = r11
            r6 = r12
            r7 = r13
            r0.<init>(r1, r2, r4, r5, r6, r7)     // Catch:{ all -> 0x0099 }
            java.util.List<com.flurry.sdk.ja> r1 = r9.D     // Catch:{ all -> 0x0099 }
            r1.add(r0)     // Catch:{ all -> 0x0099 }
            java.lang.String r1 = a     // Catch:{ all -> 0x0099 }
            java.lang.StringBuilder r2 = new java.lang.StringBuilder     // Catch:{ all -> 0x0099 }
            java.lang.String r3 = "Error logged: "
            r2.<init>(r3)     // Catch:{ all -> 0x0099 }
            java.lang.String r0 = r0.a     // Catch:{ all -> 0x0099 }
            java.lang.StringBuilder r0 = r2.append(r0)     // Catch:{ all -> 0x0099 }
            java.lang.String r0 = r0.toString()     // Catch:{ all -> 0x0099 }
            com.flurry.sdk.km.e(r1, r0)     // Catch:{ all -> 0x0099 }
        L_0x0053:
            monitor-exit(r9)
            return
        L_0x0055:
            r1 = r0
            goto L_0x000d
        L_0x0057:
            if (r1 == 0) goto L_0x00a0
            r8 = r0
        L_0x005a:
            java.util.List<com.flurry.sdk.ja> r0 = r9.D     // Catch:{ all -> 0x0099 }
            int r0 = r0.size()     // Catch:{ all -> 0x0099 }
            if (r8 >= r0) goto L_0x0053
            java.util.List<com.flurry.sdk.ja> r0 = r9.D     // Catch:{ all -> 0x0099 }
            java.lang.Object r0 = r0.get(r8)     // Catch:{ all -> 0x0099 }
            com.flurry.sdk.ja r0 = (com.flurry.sdk.ja) r0     // Catch:{ all -> 0x0099 }
            java.lang.String r1 = r0.a     // Catch:{ all -> 0x0099 }
            if (r1 == 0) goto L_0x009c
            java.lang.String r1 = "uncaught"
            java.lang.String r0 = r0.a     // Catch:{ all -> 0x0099 }
            boolean r0 = r1.equals(r0)     // Catch:{ all -> 0x0099 }
            if (r0 != 0) goto L_0x009c
            long r0 = java.lang.System.currentTimeMillis()     // Catch:{ all -> 0x0099 }
            java.lang.Long r2 = java.lang.Long.valueOf(r0)     // Catch:{ all -> 0x0099 }
            com.flurry.sdk.ja r0 = new com.flurry.sdk.ja     // Catch:{ all -> 0x0099 }
            java.util.concurrent.atomic.AtomicInteger r1 = r9.r     // Catch:{ all -> 0x0099 }
            int r1 = r1.incrementAndGet()     // Catch:{ all -> 0x0099 }
            long r2 = r2.longValue()     // Catch:{ all -> 0x0099 }
            r4 = r10
            r5 = r11
            r6 = r12
            r7 = r13
            r0.<init>(r1, r2, r4, r5, r6, r7)     // Catch:{ all -> 0x0099 }
            java.util.List<com.flurry.sdk.ja> r1 = r9.D     // Catch:{ all -> 0x0099 }
            r1.set(r8, r0)     // Catch:{ all -> 0x0099 }
            goto L_0x0053
        L_0x0099:
            r0 = move-exception
            monitor-exit(r9)
            throw r0
        L_0x009c:
            int r0 = r8 + 1
            r8 = r0
            goto L_0x005a
        L_0x00a0:
            java.lang.String r0 = a     // Catch:{ all -> 0x0099 }
            java.lang.String r1 = "Max errors logged. No more errors logged."
            com.flurry.sdk.km.e(r0, r1)     // Catch:{ all -> 0x0099 }
            goto L_0x0053
        */
        throw new UnsupportedOperationException("Method not decompiled: com.flurry.sdk.jh.a(java.lang.String, java.lang.String, java.lang.String, java.lang.Throwable):void");
    }

    /* access modifiers changed from: private */
    /* JADX WARNING: Code restructure failed: missing block: B:12:0x001b, code lost:
        if (r20.w.isEmpty() == false) goto L_0x001d;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public synchronized void a(boolean r21, long r22) {
        /*
            r20 = this;
            monitor-enter(r20)
            r0 = r20
            boolean r2 = r0.o     // Catch:{ all -> 0x008c }
            if (r2 != 0) goto L_0x0011
            r2 = 3
            java.lang.String r3 = a     // Catch:{ all -> 0x008c }
            java.lang.String r4 = "Analytics disabled, not sending agent report."
            com.flurry.sdk.km.a((int) r2, (java.lang.String) r3, (java.lang.String) r4)     // Catch:{ all -> 0x008c }
        L_0x000f:
            monitor-exit(r20)
            return
        L_0x0011:
            if (r21 != 0) goto L_0x001d
            r0 = r20
            java.util.List<com.flurry.sdk.jf> r2 = r0.w     // Catch:{ all -> 0x008c }
            boolean r2 = r2.isEmpty()     // Catch:{ all -> 0x008c }
            if (r2 != 0) goto L_0x000f
        L_0x001d:
            r2 = 3
            java.lang.String r3 = a     // Catch:{ all -> 0x008c }
            java.lang.String r4 = "generating agent report"
            com.flurry.sdk.km.a((int) r2, (java.lang.String) r3, (java.lang.String) r4)     // Catch:{ all -> 0x008c }
            r19 = 0
            com.flurry.sdk.jd r3 = new com.flurry.sdk.jd     // Catch:{ Exception -> 0x008f }
            com.flurry.sdk.jy r2 = com.flurry.sdk.jy.a()     // Catch:{ Exception -> 0x008f }
            java.lang.String r4 = r2.d     // Catch:{ Exception -> 0x008f }
            com.flurry.sdk.ju r2 = com.flurry.sdk.ju.a()     // Catch:{ Exception -> 0x008f }
            java.lang.String r5 = r2.g()     // Catch:{ Exception -> 0x008f }
            r0 = r20
            boolean r6 = r0.j     // Catch:{ Exception -> 0x008f }
            com.flurry.sdk.jl r2 = com.flurry.sdk.jl.a()     // Catch:{ Exception -> 0x008f }
            boolean r7 = r2.c()     // Catch:{ Exception -> 0x008f }
            r0 = r20
            long r8 = r0.t     // Catch:{ Exception -> 0x008f }
            r0 = r20
            java.util.List<com.flurry.sdk.jf> r12 = r0.w     // Catch:{ Exception -> 0x008f }
            com.flurry.sdk.jl r2 = com.flurry.sdk.jl.a()     // Catch:{ Exception -> 0x008f }
            java.util.Map<com.flurry.sdk.jt, byte[]> r2 = r2.a     // Catch:{ Exception -> 0x008f }
            java.util.Map r13 = java.util.Collections.unmodifiableMap(r2)     // Catch:{ Exception -> 0x008f }
            r0 = r20
            com.flurry.sdk.hs r2 = r0.G     // Catch:{ Exception -> 0x008f }
            java.util.Map r14 = r2.a()     // Catch:{ Exception -> 0x008f }
            r0 = r20
            java.util.Map<java.lang.String, java.util.List<java.lang.String>> r15 = r0.x     // Catch:{ Exception -> 0x008f }
            com.flurry.sdk.ka r2 = com.flurry.sdk.ka.a()     // Catch:{ Exception -> 0x008f }
            java.util.HashMap r16 = r2.b()     // Catch:{ Exception -> 0x008f }
            long r17 = java.lang.System.currentTimeMillis()     // Catch:{ Exception -> 0x008f }
            r10 = r22
            r3.<init>(r4, r5, r6, r7, r8, r10, r12, r13, r14, r15, r16, r17)     // Catch:{ Exception -> 0x008f }
            byte[] r2 = r3.a     // Catch:{ Exception -> 0x008f }
        L_0x0074:
            if (r2 != 0) goto L_0x00a7
            java.lang.String r2 = a     // Catch:{ all -> 0x008c }
            java.lang.String r3 = "Error generating report"
            com.flurry.sdk.km.e(r2, r3)     // Catch:{ all -> 0x008c }
        L_0x007d:
            r0 = r20
            java.util.List<com.flurry.sdk.jf> r2 = r0.w     // Catch:{ all -> 0x008c }
            r2.clear()     // Catch:{ all -> 0x008c }
            r0 = r20
            com.flurry.sdk.kf<java.util.List<com.flurry.sdk.jf>> r2 = r0.i     // Catch:{ all -> 0x008c }
            r2.b()     // Catch:{ all -> 0x008c }
            goto L_0x000f
        L_0x008c:
            r2 = move-exception
            monitor-exit(r20)
            throw r2
        L_0x008f:
            r2 = move-exception
            java.lang.String r3 = a     // Catch:{ all -> 0x008c }
            java.lang.StringBuilder r4 = new java.lang.StringBuilder     // Catch:{ all -> 0x008c }
            java.lang.String r5 = "Exception while generating report: "
            r4.<init>(r5)     // Catch:{ all -> 0x008c }
            java.lang.StringBuilder r2 = r4.append(r2)     // Catch:{ all -> 0x008c }
            java.lang.String r2 = r2.toString()     // Catch:{ all -> 0x008c }
            com.flurry.sdk.km.e(r3, r2)     // Catch:{ all -> 0x008c }
            r2 = r19
            goto L_0x0074
        L_0x00a7:
            r3 = 3
            java.lang.String r4 = a     // Catch:{ all -> 0x008c }
            java.lang.StringBuilder r5 = new java.lang.StringBuilder     // Catch:{ all -> 0x008c }
            java.lang.String r6 = "generated report of size "
            r5.<init>(r6)     // Catch:{ all -> 0x008c }
            int r6 = r2.length     // Catch:{ all -> 0x008c }
            java.lang.StringBuilder r5 = r5.append(r6)     // Catch:{ all -> 0x008c }
            java.lang.String r6 = " with "
            java.lang.StringBuilder r5 = r5.append(r6)     // Catch:{ all -> 0x008c }
            r0 = r20
            java.util.List<com.flurry.sdk.jf> r6 = r0.w     // Catch:{ all -> 0x008c }
            int r6 = r6.size()     // Catch:{ all -> 0x008c }
            java.lang.StringBuilder r5 = r5.append(r6)     // Catch:{ all -> 0x008c }
            java.lang.String r6 = " reports."
            java.lang.StringBuilder r5 = r5.append(r6)     // Catch:{ all -> 0x008c }
            java.lang.String r5 = r5.toString()     // Catch:{ all -> 0x008c }
            com.flurry.sdk.km.a((int) r3, (java.lang.String) r4, (java.lang.String) r5)     // Catch:{ all -> 0x008c }
            com.flurry.sdk.hr r3 = com.flurry.sdk.hr.a()     // Catch:{ all -> 0x008c }
            com.flurry.sdk.je r3 = r3.b     // Catch:{ all -> 0x008c }
            java.lang.StringBuilder r4 = new java.lang.StringBuilder     // Catch:{ all -> 0x008c }
            r4.<init>()     // Catch:{ all -> 0x008c }
            int r5 = com.flurry.sdk.jz.a()     // Catch:{ all -> 0x008c }
            java.lang.StringBuilder r4 = r4.append(r5)     // Catch:{ all -> 0x008c }
            java.lang.String r4 = r4.toString()     // Catch:{ all -> 0x008c }
            com.flurry.sdk.jy r5 = com.flurry.sdk.jy.a()     // Catch:{ all -> 0x008c }
            java.lang.String r5 = r5.d     // Catch:{ all -> 0x008c }
            r3.b(r2, r5, r4)     // Catch:{ all -> 0x008c }
            goto L_0x007d
        */
        throw new UnsupportedOperationException("Method not decompiled: com.flurry.sdk.jh.a(boolean, long):void");
    }

    public final synchronized void d() {
        km.a(4, a, "Saving persistent agent data.");
        this.i.a(this.w);
    }

    /* access modifiers changed from: private */
    public synchronized void e() {
        km.a(4, a, "Loading persistent session report data.");
        List a2 = this.i.a();
        if (a2 != null) {
            this.w.addAll(a2);
        } else if (this.h.exists()) {
            km.a(4, a, "Legacy persistent agent data found, converting.");
            ji a3 = hu.a(this.h);
            if (a3 != null) {
                boolean z2 = a3.a;
                long j2 = a3.b;
                if (j2 <= 0) {
                    jk.a();
                    j2 = jk.c();
                }
                this.j = z2;
                this.t = j2;
                f();
                List<T> unmodifiableList = Collections.unmodifiableList(a3.c);
                if (unmodifiableList != null) {
                    this.w.addAll(unmodifiableList);
                }
            }
            this.h.delete();
            d();
        }
    }

    /* access modifiers changed from: private */
    public void f() {
        SharedPreferences.Editor edit = jy.a().a.getSharedPreferences("FLURRY_SHARED_PREFERENCES", 0).edit();
        edit.putBoolean("com.flurry.sdk.previous_successful_report", this.j);
        edit.putLong("com.flurry.sdk.initial_run_time", this.t);
        edit.putString("com.flurry.sdk.api_key", jy.a().d);
        edit.apply();
    }

    static /* synthetic */ void d(jh jhVar) {
        SharedPreferences sharedPreferences = jy.a().a.getSharedPreferences("FLURRY_SHARED_PREFERENCES", 0);
        jhVar.j = sharedPreferences.getBoolean("com.flurry.sdk.previous_successful_report", false);
        jk.a();
        jhVar.t = sharedPreferences.getLong("com.flurry.sdk.initial_run_time", jk.c());
        jhVar.u = sharedPreferences.getString("com.flurry.sdk.api_key", "");
        if (TextUtils.isEmpty(jhVar.u) && jhVar.t > 0) {
            jhVar.u = jy.a().d;
        } else if (!jhVar.u.equals(jy.a().d)) {
            jk.a();
            jhVar.t = jk.c();
        }
    }
}
